#include "stdafx.h"
#include "ImageProcOpenCVLib.h"
#include "IResize.h"
#include "IAbsDiff.h"
#include "IBlur.h"
#include "IGaussianBlur.h"
#include "ICanny.h"
#include "IAdd.h"
#include "IAddMask.h"
#include "IAddWeighted.h"
#include "ISub.h"
#include "ISubMask.h"
#include "IDivide.h"
#include "IDivideScale.h"
#include "IMultiply.h"
#include "IBitNot.h"
#include "IBitAnd.h"
#include "IBitOr.h"
#include "IBitXor.h"
#include "IContourFind.h"
//#include "IAccumulateWeighted.h"

IMAGEPROCOPENCVLIB_API IImageProcStepLibDyn *CreateImageProcStepLib() //this function name must match ImageExptLib::CreateFunctionName 
{
	return new ImageProcOpenCVLib();
}

ImageProcOpenCVLib::ImageProcOpenCVLib(void) :
	_LibApi('\0')
{
	_LibApi = new ImageProcStepLibAuto();
							//todo - get this information from VS_VERSION_INFO so it is consistent with DLL file props
	_LibApi->SetLibNameVersion(GetLibName(), GetLibVersion(), GetLibInterfaceVersion());
	_LibApi->SetLibOwnerDetails("Maximodex Limited", "Copyright 2012, Will Stott", "www.maximodex.com/ProductSupport/ImageCurator/ImageProcLibs/ImageProcOpenCVLib");
	_LibApi->SetLibDescription("OpenCV Library v1.0.0.1 - Developed by Yuchen Wang");

	IResize *resize = new IResize();
	if(_LibApi->AddFunction(resize) == false)
		delete resize;

	IAbsDiff *AbsDiff = new IAbsDiff();
	if(_LibApi->AddFunction(AbsDiff) == false)
		delete AbsDiff;

	IBlur *blur = new IBlur();
	if(_LibApi->AddFunction(blur) == false)
		delete blur;

	IGaussianBlur *GBlur = new IGaussianBlur();
	if(_LibApi->AddFunction(GBlur) == false)
		delete GBlur;

	ICanny *Canny = new ICanny();
	if(_LibApi->AddFunction(Canny) == false)
		delete Canny;

	IAdd *Add = new IAdd();
	if(_LibApi->AddFunction(Add) == false)
		delete Add;

	IAddWeighted *AddW = new IAddWeighted();
	if(_LibApi->AddFunction(AddW) == false)
		delete AddW;

	IAddMask *AddMa = new IAddMask();
	if(_LibApi->AddFunction(AddMa) == false)
		delete AddMa;

	ISub *Sub = new ISub();
	if(_LibApi->AddFunction(Sub) == false)
		delete Sub;

	ISubMask *SubMa = new ISubMask();
	if(_LibApi->AddFunction(SubMa) == false)
		delete SubMa;

	IDivide *Div = new IDivide();
	if(_LibApi->AddFunction(Div) == false)
		delete Div;

	IDivideScale *DivS = new IDivideScale();
	if(_LibApi->AddFunction(DivS) == false)
		delete DivS;

	IMultiply *Mult = new IMultiply();
	if(_LibApi->AddFunction(Mult) == false)
		delete Mult;

	//IAccumulateWeighted *AccW = new IAccumulateWeighted();
	//if(_LibApi->AddFunction(AccW) == false)
	//	delete AccW;
	//.... add other functions

	IBitNot *bNot = new IBitNot();
	if(_LibApi->AddFunction(bNot) == false)
		delete bNot;

	IBitAnd *bAnd = new IBitAnd();
	if(_LibApi->AddFunction(bAnd) == false)
		delete bAnd;

	IBitOr *bOr = new IBitOr();
	if(_LibApi->AddFunction(bOr) == false)
		delete bOr;

	IBitXor *bXor = new IBitXor();
	if(_LibApi->AddFunction(bXor) == false)
		delete bXor;

	IContourFind *ContourF = new IContourFind();
	if(_LibApi->AddFunction(ContourF) == false)
		delete ContourF;

	_LibApi->Validate();
}


ImageProcOpenCVLib::~ImageProcOpenCVLib(void)
{
	ImageExptLib::LogMsg("ImageProcOpenCVLib::~ImageProcOpenCVLib", "entry");	
	if (_LibApi != '\0')
	{
		ImageExptLib::LogMsg("ImageProcOpenCVLib::~ImageProcOpenCVLib", "delete _LibApi");	
		delete _LibApi;
	}
	_LibApi = '\0';
	ImageExptLib::LogMsg("ImageProcOpenCVLib::~ImageProcOpenCVLib", "exit");	
}

bool ImageProcOpenCVLib::Run(const char *fnName, ProcParamsInputs *inputs, ProcParamsOutputs *outputs)
{
	bool rc = false;
	
	return rc;
}
